//
//  WJBaseView.m
//  WJBSApp
//
//  Created by dllo on 16/7/13.
//  Copyright © 2016年 王景伟. All rights reserved.
//

#import "WJBaseView.h"

@interface WJBaseView ()

@property (nonatomic,retain) UILabel *lable;

@end


@implementation WJBaseView

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

// 创建6个图片的方法
- (instancetype)initWithFrame:(CGRect)frame imageName:(NSString *)imageName name:(NSString *)name {
    self = [super initWithFrame:frame];
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.width)];
    image.image = [UIImage imageNamed:imageName];
    [self addSubview:image];
    
    _lable = [[UILabel alloc]initWithFrame:CGRectMake(0,self.bounds.size.width, self.bounds.size.width, self.bounds.size.height - self.bounds.size.width)];
    [self addSubview:_lable];
    _lable.text = name;
    _lable.textAlignment = 1;
    
    [self changeColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor) name:@"changeColor" object:nil];
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    [self changeColor1];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor1) name:@"changeColor" object:nil];
    return self;
}

- (void)changeColor {
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
        _lable.textColor = BSWhiteColor;
    }else{
        _lable.textColor = BSBlackColor;
    }
}
- (void)changeColor1 {
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
        self.backgroundColor = FIRBLACKCOLOR;
    }else{
        self.backgroundColor = LABLECOLOR;
    }
}
@end
